#include  <stdlib.h>

#include  <stdio.h>

#define   N   10

double fun(double  x[],double  *av)

{ int  i,j;    double  d,s;

  s=0;

  for(i=0; i<N; i++)  s = s +x[i];

/**********found**********/

  *av=s/N;

  d=32767;

  for(i=0; i<N; i++)

    if(x[i]<*av && *av - x[i]<=d){

/**********found**********/

      d=*av-x[i];  j=i;}

/**********found**********/

  return x[j];

}

main()

{ int  i;    double  x[N]= {46,30,32,40,6,17,45,15,48,26};

  double  av,m;

  for(i=0; i<N; i++) printf("%4.0f ",x[i]);

  printf("\n");

  m=fun(x,&av);

  printf("\nThe average is: %f\n",av);

  printf("m=%5.0f ",m);

  printf("\n");

  getchar();

}

